﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Orchard.ContentManagement.Drivers;
using Wicresoft.Movies.Models;

namespace Wicresoft.Movies.Drivers
{
    public class MoviePartDriver : ContentPartDriver<MoviePart>
    {

        protected override string Prefix
        {
            get { return "Movie"; }
        }

        protected override DriverResult Display(MoviePart part, string displayType, dynamic shapeHelper) {
            return ContentShape("Parts_Movie",
                                () => shapeHelper.Parts_Movie(MoviePart: part));
        }


        //get
        protected override DriverResult Editor(MoviePart part, dynamic shapeHelper)
        {
            return ContentShape("Parts_Movie_Edit", 
                () =>shapeHelper.EditorTemplate(
                    TemplateName: "Parts/Movie",
                    Model: part, Prefix:Prefix));
        }

        //post
        protected override DriverResult Editor(MoviePart part, Orchard.ContentManagement.IUpdateModel updater, dynamic shapeHelper) {
            //part.IMDB_ID = "23";
            //part.Rating = MPAARating.PG;
            //part.YearReleased = 2012;
            updater.TryUpdateModel(part, Prefix, null, null);
            return Editor(part, shapeHelper);
        }
    }
}